package com.czx.controller;

import com.czx.entity.Comment;
import com.czx.common.security.UserTokenThreadLocal;
import com.czx.service.CommentService;
import com.czx.vo.UserToken;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
@Controller
public class CommentController {
    @Autowired
    private  CommentService commentService;
    @RequestMapping("/addComment")
    public String addComment(Comment comment,Integer pid){
        UserToken userToken = UserTokenThreadLocal.get();
        comment.setTargetName(userToken.getUser().getUsername());
        comment.setUserId(userToken.getUser().getId());
        commentService.addComment(comment,pid);

        return "redirect:/disDetail?pid="+pid;
    }
}
